package myJs.myPkg

import myJs.myPkg.jquery.JQuery
import myJs.myPkg.jsext._

import scala.language.implicitConversions
import scala.scalajs.js


/**
 * Created by yz on 2019/3/14
 */

@js.native
trait BootstrapValidator extends js.Object {

  def defaultSubmit(): js.Any = js.native

  def updateMessage(field: String, validator: String, message: String): js.Any = js.native

  def updateStatus(field: String, status: String, validator: String): js.Any = js.native

}

trait BootstrapValidatorJQuery extends js.Object {

  def bootstrapValidator(method: String, fieldName: String): JQuery = scalajs.js.native

  def bootstrapValidator(method: String, jq: JQuery): JQuery = scalajs.js.native

  def bootstrapValidator(method: String, fieldName: String, enabled: Boolean): JQuery = scalajs.js.native

  def bootstrapValidator(method: String, jq: JQuery, enabled: Boolean): JQuery = scalajs.js.native

  def bootstrapValidator(dict: js.Dictionary[js.Any]): JQuery = scalajs.js.native

}

object BootstrapValidatorOptions extends BootstrapValidatorOptionsBuilder(noOpts)

class BootstrapValidatorOptionsBuilder(val dict: OptMap) extends JSOptionBuilder[BootstrapValidatorOptions, BootstrapValidatorOptionsBuilder](new BootstrapValidatorOptionsBuilder(_)) {

  def showPreview(v: Boolean) = jsOpt("showPreview", v)

  def browseLabel(v: String) = jsOpt("browseLabel", v)

  def removeLabel(v: String) = jsOpt("removeLabel", v)

  def language(v: String) = jsOpt("language", v)

}

trait BootstrapValidatorOptions extends js.Object {

}

trait BootstrapValidatorJQueryImplicits {
  implicit def implicitBootstrapValidatorJQuery(jq: JQuery): BootstrapValidatorJQuery = {
    jq.asInstanceOf[BootstrapValidatorJQuery]
  }
}
